package thread.demo01;

import com.sun.media.jfxmedia.logging.Logger;
import lombok.AllArgsConstructor;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import lombok.extern.slf4j.XSlf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j
@AllArgsConstructor
public class Callable01 implements Callable<Boolean> {
    private String url;
    private String name;

// https://www.bilibili.com/video/BV1V4411p7EF?p=9&spm_id_from=pageDriver
    @Override
    public Boolean call() throws Exception {
        downLoader.downLoader(url,name);
        System.out.println("下载了 图片为 ："+name);
        return true;
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable01 t2 = new Callable01("https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2390255124,2789605295&fm=26&gp=0.jpg","t1.jpg");
        Callable01 t1 = new Callable01("https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/0b46f21fbe096b636678ddd40c338744eaf8acd5.jpg","t2.jpg");
        Callable01 t3 = new Callable01("https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2248364240,810524291&fm=26&gp=0.jpg","t3.jpg");
        ExecutorService executorService =Executors.newFixedThreadPool(3);
        System.out.println("executorService.submit(t1) = " + executorService.submit(t1).get());
        System.out.println("executorService.submit(t2) = " + executorService.submit(t2).get());
        System.out.println("executorService.submit(t3) = " + executorService.submit(t3).get());
        executorService.shutdownNow();

    }



}
